<template>
  <div>
    <div class="shangpin" v-for="(item, index) in takeDeliveryArr" :key="index">
      <div class="shangpin_tops">
        <span>商品描述</span>
        <van-icon name="arrow" class="b1" />
      </div>

      <div class="content">
        <div class="photo">
          <img src="../assets/我的客户.png" alt="" />
        </div>
        <ul>
          <li>{{ item.title }}</li>
          <li>
            <p>下单时间</p>
            <p>{{ item.sendTime }}</p>
          </li>
          <li>
            <p>下单人</p>
            <p>{{ item.orderUserName }}</p>
          </li>
        </ul>
      </div>

      <div class="foots">
        <van-button
          class="van_btn"
          color="#ccc"
          round
          @click="btn(item.serialNo)"
          >收货</van-button
        >
      </div>
    </div>
  </div>
</template>

<script>
import { getTakeDelivery, getConfirmReceipt } from "@/request/api";

export default {
  data() {
    return {
      takeDeliveryArr: [],
    };
  },
  created() {
    this.getlist();
  },
  methods: {
    getlist() {
      getTakeDelivery({
        current: 1,
        size: 10,
        keyword: "",
      }).then((res) => {
        console.log(res);
        this.takeDeliveryArr = res.data.records;
      });
    },

    btn(val) {
      this.$dialog
        .confirm({
          title: "是否确认收货？",
        })
        .then(() => {
          getConfirmReceipt({
            serialNo: val,
          }).then((res) => {
            console.log(res);
            if (res.errCode == 0) {
              this.getlist();
            }
          });
        })
        .catch(() => {
          // on cancel
        });
    },
  },
};
</script>

<style scoped>
.shangpin {
  background: #fff;
  margin-bottom: 0.5rem;
}
.shangpin_tops {
  display: flex;
  justify-content: space-between;
  padding: 0 1rem;
  margin-top: 0.5rem;
}
span,
.b1 {
  padding: 0.8rem 0;
}
.content {
  background: #fff;
  border-top: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
  display: flex;
  padding: 1rem;
}
.photo {
  flex: 1;
}
.content ul {
  flex: 4;
}
.content ul li {
  display: flex;
}
.photo img {
  width: 80%;
}
.foots {
  padding: 0.5rem 0;
}
.van_btn {
  padding: 0 1.8rem;
  margin-left: 70%;
}
</style>